package process;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.Socket;

import android.R;
import android.content.res.Resources.Theme;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;

public class SendFileUDP {
	private int m_port = 8282;
	private String m_Start = "SendFileName";
	String[]g_ArrayOfIP;
	SendAllFile send = new SendAllFile();
	


public String SendUsingUDP(ProgressBar pB,String m_Path ,String m_filename,String[] ArrayOfIP)
{
	
	String thongbao ="";
	SendAllFile send = new SendAllFile();
	for(int i=0;i<ArrayOfIP.length;i++)
	{
		
		String m_host=ArrayOfIP[i];
		int kq = send.SendInfoStartSendUDP(m_host, m_port, m_Start);
		if(kq==1)
		{
			 int ports = 8181;
				int kq1 = send.sendfilename(m_host, ports, m_filename);
				
				if(kq1!=0)
				{
					int portss = 8383;
					int kq3 = send.SenContentFile(pB,m_Path, m_filename, m_host, portss);
					thongbao = "successful";
					
				}
				else
				{
					thongbao = "unsuccessful";
				}
		}
	}
	return thongbao;
	
	}
}


